<?php
namespace app\controllers;


use app\logic\OrderLogic;
use app\models\Area;
use yii;

class OrderController extends BackendController
{

    public function actionIndex()
    {
        $query = Yii::$app->request->get('form', []);
        $page = Yii::$app->request->get('page', 1);
        $orderLogic = new OrderLogic();
        $this->data['breadcrumbs'] = '订单管理';
        //var_dump($orderLogic->getOrder($query, $page));exit;
        return $this->render('index', [
            'order' => $orderLogic->getOrder($query, $page),
            'query' => $query
        ]);
    }

    public function actionCancel()
    {
        $query = Yii::$app->request->get('form', []);
        $page = Yii::$app->request->get('page', 1);
        $orderLogic = new OrderLogic();
        $this->data['breadcrumbs'] = '核销单管理';
        return $this->render('cancel', [
            'cancel' => $orderLogic->getCancel($query, $page),
            'query' => $query
        ]);
    }

    public function actionIncome()
    {
        if(!Yii::$app->request->post()){
            $province = Area::find()->where(['region_level'=>1])->asArray()->all();
            return $this->render('income', [
                'province'=>$province,
                'theme' => '/assets/',
                'actionUrl' => U('goods/add')
            ]);
        }else{
            $orderLogic = new OrderLogic();
            $type = Yii::$app->request->post('type');
            echo json_encode($orderLogic->getMoney($type));
        }
    }





}